package com.terrace.web.constant;

import org.apache.commons.lang.StringUtils;

import com.terrace.db.system.mapper.entity.Icon;
import com.terrace.db.system.service.IconService;
import com.terrace.core.utils.ApplicationContextUtil;

/**
 * 图标
 * @author jiangyg
 *
 */
public class IconConstant {
	
	private static IconService iconService;
	
	private static IconService getIconService() {
		if (iconService == null) {
			synchronized (IconConstant.class) {
				if (iconService == null) {
					iconService = ApplicationContextUtil.getContext().getBean(IconService.class);
				}
			}
		}
		return iconService;
	}

	/**
	 * 获取图标样式
	 * @param code
	 * @return
	 */
	public static String obtainIconClass(String code) {
		Icon icon = getIconService().selectIconByCode(code);
		if (icon != null && StringUtils.isNotBlank(icon.getIconClass())) {
			return icon.getIconClass();
		}
		return code;
	}
	
}
